package com.nbcb.nwql.common.rtnvo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class ApiResponse<T> {
    private Integer code;
    private String msg;
    private Object data;

    public static <T> ApiResponse ok(T data) {
        //log.info("返回成功");
        return ok(200, "调用成功", data);
    }

    public static ApiResponse success(Integer code, String msg) {
        //log.info("返回成功");
        return ok(code, msg, null);
    }

    public static <T> ApiResponse fail(T data) {
        //log.info("返回成功");
        return erro(500, "调用失败", data);
    }

    public static <T> ApiResponse erro(Integer code, String msg, T data) {
        //log.info("返回成功");
        return new ApiResponse(code, msg, data);
    }

    public static <T> ApiResponse ok(Integer code, String msg, T data) {
        //log.info("返回成功");
        return new ApiResponse(code, msg, data);
    }
}